#!/usr/bin/perl
# autodefine.pl
use warnings;
use strict;

sub my_subroutine {
   print "Defining sub...\n";

   # uncomment next line and remove 'no warnings' for Perl < 5.6
   # local $^W = 0;
   eval 'no warnings; sub my_subroutine { print "Autodefined!\n"; }';

   &my_subroutine;
}

my_subroutine;
my_subroutine;